import { createRouter, createWebHashHistory } from 'vue-router'
import LoginView from '@/views/LoginView.vue'
import TabNavBar from '@/components/layouts/TabNavBar.vue'
import HomeView from '@/views/HomeView.vue'
import ChatView from '@/views/ChatView.vue'
import UserView from '@/views/UserView.vue'
import AboutView from '@/views/AboutView.vue'
import DetailView from '@/views/DetailView.vue'
import AgreementView from '@/views/AgreementView.vue'

const router = createRouter({
  history: createWebHashHistory("/"),
  routes: [
    {
      path: "/",
      redirect: "/tab/home",
      },
    {
      path: '/login',
      name: 'login',
      component: LoginView
    },
    {
      path: '/about',
      name: 'about',
      component: AboutView
    },
    {
      path: '/agreement',
      name: 'agreement',
      component: AgreementView
    },
    {
      path: '/detail',
      name: 'detail',
      component: DetailView,
      props: true
    },
    {
      path: '/tab',
      // name: 'home',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: TabNavBar,
      children: [
        {
          path: 'home',
          name: 'home',
          meta: {
            keepAlive: true,
          },
          component: HomeView
        },
        {
          path: 'chat',
          name: 'chat',
          meta: {
            keepAlive: true,
          },
          component: ChatView
        },
        {
          path: 'user',
          name: 'user',
          meta: {
            keepAlive: true,
          },
          component: UserView
        }
      ]
    }
  ]
})

export default router
